package com.music.message.config;

import com.music.common.core.constant.Constants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Author 史豪通
 * Date 2024/10/12 10:22
 */
@Configuration
public class UserRabbitMqConfig {

    @Bean
    public Queue queue() {
        return new Queue(Constants.MESSAGE_USER_QUEUE, false, false, false, null);
    }

    @Bean(name = "directExchange")
    public DirectExchange directExchange() {
        return new DirectExchange(Constants.MESSAGE_USER_EXCHANGE, false, false, null);
    }

    @Bean
    public Binding binding(Queue queue, DirectExchange directExchange) {
        return BindingBuilder.bind(queue).to(directExchange).with(Constants.MESSAGE_USER_ROUTING);
    }
}
